package com.gm.commonlib.network.basenetwork.config;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import okhttp3.Interceptor;

public class HttpOptions {

    public static class Builder {
       public int connectTimeout;
        public int readTimeout;
        public int writeTimeout;
        public File cacheFile;
        public long cacheSize;
        public String baseUrl;
        public List<Interceptor> mInterceptors=new ArrayList<>();
        @Deprecated
        public Builder setConnectTimeout(String baseUrl) {
            this.baseUrl = baseUrl;
            return this;
        }
        @Deprecated
        public Builder setConnectTimeout(int connectTimeout) {
            this.connectTimeout = connectTimeout;
            return this;
        }

        public Builder setReadTimeout(int readTimeout) {
            this.readTimeout = readTimeout;
            return this;
        }

        public Builder setWriteTimeout(int writeTimeout) {
            this.writeTimeout = writeTimeout;
            return this;
        }

        public Builder setCacheFile(File cacheFile) {
            this.cacheFile = cacheFile;
            return this;
        }

        public Builder setCacheSize(int  cacheSize) {
            this.cacheSize = cacheSize;
            return this;
        }


        public Builder setInterceptors(List<Interceptor> interceptors) {
            mInterceptors.addAll(interceptors);
            return this;
        }
        public Builder setInterceptor(Interceptor interceptor) {
            mInterceptors.add(interceptor);
            return this;
        }


        public HttpOptions build() {
            return new HttpOptions();
        }
    }
}
